<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Modules\Admin\Services\PermissionService;

class RefreshPermissionToRouteMajorsTable extends Migration
{
    /**
     * 说明：刷新 '组织机构.专业管理'和 '指标管理.指标体系' 的权限
     *
     * @return
     * @param   type
     * @author  zhangpppppppp (2561525846@qq.com)
     */
    public function up()
    {

        $search_alias = ['组织机构.专业管理', '指标管理.指标体系'];

        // 获得路由的实例
        $router = app('Illuminate\Routing\Router');

        foreach ($search_alias as $num_key => $search_alias_value) {
            /* 1、先删除和 控制台相关是控制台 */
            PermissionService::getInstance()->delPermission('all', $search_alias_value);
            /* 2、刷新控制台的权限 */
            PermissionService::getInstance()->refreshPermissionByRoute($router, 'admin', $search_alias_value);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        return null;
    }
}
